package com.ithaixiang.demo.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ithaixiang.demo.domian.DataEntity;
import com.ithaixiang.demo.mapper.DataEntityMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.soap.DetailEntry;
import java.util.List;

@RequestMapping("/test")
@RestController
@Slf4j
public class DataEntityController {
    @Autowired
    DataEntityMapper dataEntityMapper;
    @GetMapping("/page")
    public PageInfo<DataEntity> pagAll(int pageNum, int pageSize, String name) {
        PageHelper.startPage(pageNum, pageSize);
        //就是一个正常的查询所有的sql
        List<DataEntity> lists =  dataEntityMapper.findAllPage(name);
        PageInfo<DataEntity> pageInfo = new PageInfo(lists);
        List<DataEntity> list = pageInfo.getList();

        for (DataEntity dataEntity : list) {
            dataEntity.setChenji("");
            dataEntity.setXuefen("");
        }
        pageInfo.setList(list);
        return pageInfo;
    }
//    @GetMapping("/page")
//    public void pagAll(String name) {
//        List<DataEntity> lists =  dataEntityMapper.findAllPage(name);
//        System.out.println(lists);
//    }
    @PostMapping("/test11")
    public String test(){
        return "sussess";
    }

}
